package inf.coach.mobile;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;

import android.widget.Button;
import android.widget.EditText;

public class Rating extends Activity {
	
    public static long userid = 0;
    public static long osmid= 0;
	
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.rating);
        setTitle("Bitte wählen Sie ihre Type");
        
       	Bundle bundle = this.getIntent().getExtras();      
		userid = bundle.getLong("userid");
		osmid= bundle.getLong("osmid");
		
        final Button safety=(Button)  findViewById(R.id.button_safety);
        final Button accessibility=(Button)  findViewById(R.id.button_accessibility);
        final Button orientation=(Button)  findViewById(R.id.button_orientation);
        
        
        safety.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View arg0){
				
				Intent intent = new Intent();
				Bundle bundle = new Bundle();
				bundle.putLong("osmid", osmid);
				bundle.putLong("userid", userid);
				intent.setClass(Rating.this, RateSafe.class);
				intent.putExtras(bundle);
				startActivity(intent);
			}
			
		});
        
        accessibility.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View arg0){
				
				Intent intent = new Intent();
				Bundle bundle = new Bundle();
				bundle.putLong("osmid", osmid);
				bundle.putLong("userid", userid);
				intent.setClass(Rating.this, RateAccess.class);
				intent.putExtras(bundle);
				startActivity(intent);
			}
			
		});
        orientation.setOnClickListener(new Button.OnClickListener(){
			public void onClick(View arg0){
				
				Intent intent = new Intent();
				Bundle bundle = new Bundle();
				bundle.putLong("osmid", osmid);
				bundle.putLong("userid", userid);
				intent.setClass(Rating.this, RateOrientation.class);
				intent.putExtras(bundle);
				startActivity(intent);
			}
			
		});
        
	}
	 protected void dialoggoback() { 
	        AlertDialog.Builder builder = new Builder(Rating.this); 
	        builder.setMessage("Möchten Sie zur letzten Seite zurück springen?"); 
	        builder.setTitle("Information"); 
	        builder.setPositiveButton("ok", 
	                new android.content.DialogInterface.OnClickListener() { 
	                    @Override 
	                    public void onClick(DialogInterface dialog, int which) { 
	                        dialog.dismiss(); 
	                        Rating.this.finish(); 
	                    }

	                }); 
	        builder.setNegativeButton("abbrechen", 
	                new android.content.DialogInterface.OnClickListener() { 
	                    @Override 
	                    public void onClick(DialogInterface dialog, int which) { 
	                        dialog.dismiss(); 
	                    } 
	                }); 
	        builder.create().show(); 
	    } 
	    @Override 
	    public boolean onKeyDown(int keyCode, KeyEvent event) { 
	        if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { 
	            dialoggoback(); 
	            return false; 
	        } 
	        return false; 
	    } 

}